<?php
require_once(ADDON_PATH . 'IntegralShop' . '/functions.php');

return array(
    'name' => '积分商城',
    'bzname' => 'IntegralShop',
    'type' => '1',
    'desc' => '积分商城',
    'version' => '1.0',
    'author' => '16,sg',
    'logo' => 'logo.png',
    'install_sql' => 'install.sql',
    'config' => array(
        'respond_rule' => 0,
        'entry' => 1,
        'entry_list' => array(
            'index' => '主页'
        ),
        // 配置管理
        'setting' => 1,
        'setting_list' => array(
            'mp_code' => array(
                'title' => '公众号二维码',
                'type' => 'image',
                'placeholder' => '',
                'group' => 'basic'
            ),
            'ad1' => array(
                'title' => '首页幻灯片1',
                'type' => 'image',
                'placeholder' => '',
                'group' => 'basic'
            ),
            'ad1url' => array(
                'title' => '幻灯片1跳转链接',
                'type' => 'text',
                'group' => 'basic'
            ),
            'ad2' => array(
                'title' => '首页幻灯片2',
                'type' => 'image',
                'placeholder' => '',
                'group' => 'basic'
            ),
            'ad2url' => array(
                'title' => '幻灯片2跳转链接',
                'type' => 'text',
                'group' => 'basic'
            ),
            'ad3' => array(
                'title' => '首页幻灯片3',
                'type' => 'image',
                'placeholder' => '',
                'group' => 'basic'
            ),
            'ad3url' => array(
                'title' => '幻灯片3跳转链接',
                'type' => 'text',
                'group' => 'basic'
            ),
            'share_title' => array(
                'title' => '分享标题',
                'type' => 'text',
                'group' => 'share'
            ),
            'share_imgs' => array(
                'title' => '分享图片',
                'type' => 'image',
                'group' => 'share'
            ),
            'share_desc' => array(
                'title' => '分享描述',
                'type' => 'text',
                'group' => 'share'
            ),

            'spread_need_subscribe' => array(
                'title' => '是否需要关注',
                'type' => 'radio',
                'format' => 'enum',
                'extra' => array(
                    'options' => array(
                        1 => '是',
                        0 => '否',
                    )
                ),
                'group' => 'spread'
            ),
            'spread_mark_per_time' => array(
                'title' => '推广可得多少积分',
                'type' => 'number',
                'tip' => '',
                'group' => 'spread'
            ),
        ),
        'setting_list_group' => array(
            'basic' => array(
                'title' => '基础配置',
                'is_show' => 1,
            ),
            'share' => array(
                'title' => '分享配置',
                'is_show' => 1
            ),
            'spread' => array(
                'title' => '推广配置',
                'is_show' => 1
            )
        ),
        // 菜单管理
        'menu' => 1,
        'menu_list' => array(
            'goods' => '商品管理',
            'orders' => '订单管理',
            'user_mark' => '用户积分',
            'spreads' => '积分记录',
        ),
    ),
    'model' => array(
        'goods' => array(
            'name' => 'is_good',
            'meta_title' => '商品列表',
            'btn' => array(
                array('title' => '添加', 'url' => create_addon_url('good_add'), 'class' => 'btn btn-info')
            ),
            'lists' => array(
                array('name' => 'id', 'title' => '主键', 'format' => 'hidden'),
                array('name' => 'name', 'title' => '商品名称', 'format' => 'text'),
                array('name' => 'cover', 'title' => '封面', 'format' => 'image', 'extra' => array('attr' => "width=\"150\" height=\"150\"")),
                array('name' => 'price', 'title' => '原价', 'format' => 'text'),
                array('name' => 'need_mark', 'title' => '所需积分', 'format' => 'text'),
                array('name' => 'number', 'title' => '商品数量', 'format' => 'text'),
                array(
                    'name' => 'id',
                    'title' => '操作',
                    'format' => 'custom',
                    'extra' => array(
                        'options' => array(
                            'edit' => array('title' => '编辑', 'url' => create_addon_url('good_edit', array('id' => '{id}')), 'class' => 'btn btn-primary btn-sm icon-edit'),
                            'del' => array('title' => '删除', 'url' => create_addon_url('good_delete', array('id' => '{id}')), 'class' => 'btn btn-success btn-sm icon-delete'),
                        ),
                    ),
                ),
            ),
            'list_map' => array('mpid' => get_mpid(), 'is_deleted' => 0),
            'list_order' => array('id DESC'),
        ),
        'good_add' => array(
            'name' => 'is_good',
            'title' => '添加商品',
            'fields' => array(
                array('name' => 'name', 'title' => '商品名称', 'type' => 'text', 'placeholder' => '请输入商品名称'),
                array('name' => 'cover', 'title' => '封面', 'type' => 'image'),
                array('name' => 'price', 'title' => '原价', 'type' => 'text', 'placeholder' => '请输入价格'),
                array('name' => 'need_mark', 'title' => '兑换所需积分', 'type' => 'text', 'placeholder' => '请输入兑换所需积分'),
                array('name' => 'number', 'title' => '商品总数', 'type' => 'text', 'placeholder' => '请输入商品总数'),
            ),
            'auto' => array(
                array('mpid', get_mpid()),
                array('created_at', commonTimeFormat()),
                array('updated_at', commonTimeFormat()),
            ),
            'validate' => array(
                array('name', 'require', '商品名称不能为空!', 1, 'regex', 3),
            ),
        ),
        'orders' => array(
            'name' => 'is_order',
            'meta_title' => '订单列表',
            'btn' => array(),
            'lists' => array(
                array('name' => 'id', 'title' => '主键', 'format' => 'hidden'),
                array('name' => 'openid', 'title' => '用户名', 'format' => 'function', 'extra' => array(
                    'function_name' => 'get_fans_nickname',
                    'params' => '###'
                )),
                array('name' => 'good_id', 'title' => '商品名', 'format' => 'function', 'extra' => array(
                    'function_name' => 'getGoodName',
                    'params' => '###'
                )),
                array('name' => 'need_mark', 'title' => '使用积分', 'format' => 'text'),
                array('name' => 'name', 'title' => '用户名', 'format' => 'text'),
                array('name' => 'phone', 'title' => '手机号码', 'format' => 'text'),
                array('name' => 'address', 'title' => '地址', 'format' => 'text'),
                array('name' => 'address_code', 'title' => '邮政编码', 'format' => 'text'),
                array('name' => 'status', 'title' => '状态', 'format' => 'enum', 'extra' => array('options' => \Addons\IntegralShop\Repositor\IsOrderRepositor::getStatusHtml())),
                array('name' => 'err_msg', 'title' => '备注', 'format' => 'text'),
                array('name' => 'courier_number', 'title' => '订单编号', 'format' => 'text'),
                array(
                    'name' => 'id',
                    'title' => '操作',
                    'format' => 'custom',
                    'extra' => array(
                        'options' => array(
                            'edit' => array('title' => '通过', 'url' => create_addon_url('order_set_success', array('id' => '{id}')), 'class' => 'btn btn-success btn-sm'),
                            'del' => array('title' => '拒绝', 'url' => create_addon_url('order_set_reject', array('id' => '{id}')), 'class' => 'btn btn-danger btn-sm'),
                        ),
                    ),
                ),
            ),
            'list_map' => array('mpid' => get_mpid()),
            'list_order' => array('id DESC'),
        ),
        'order_set_success' => array(
            'name' => 'is_order',
            'title' => '快递单号',
            'fields' => array(
                array('name' => 'courier_number', 'title' => '快递单号', 'type' => 'text', 'placeholder' => '请输入快递单号'),
            ),
            'auto' => array(
                array('updated_at', commonTimeFormat()),
                array('status', \Addons\IntegralShop\Repositor\IsOrderRepositor::STATUS_FANISH),
            ),
            'validate' => array(
                array('courier_number', 'require', '快递单号不能为空!', 1, 'regex', 3),
            ),
        ),
        'order_set_reject' => array(
            'name' => 'is_order',
            'title' => '拒绝原因',
            'fields' => array(
                array('name' => 'err_msg', 'title' => '拒绝原因', 'type' => 'text', 'placeholder' => '请输入拒绝原因'),
            ),
            'auto' => array(
                array('updated_at', commonTimeFormat()),
                array('status', \Addons\IntegralShop\Repositor\IsOrderRepositor::STATUS_REJECT),
            ),
            'validate' => array(
                array('err_msg', 'require', '拒绝原因不能为空!', 1, 'regex', 3),
            ),
        ),
        'spreads' => array(
            'name' => 'is_spreads_record',
            'meta_title' => '积分历史记录',
            'btn' => array(),
            'lists' => array(
                array('name' => 'id', 'title' => '主键', 'format' => 'hidden'),
                array('name' => 'openid', 'title' => '用户', 'format' => 'function', 'extra' => array(
                    'function_name' => 'get_fans_nickname',
                    'params' => '###'
                )),
                array('name' => 'event_type', 'title' => '事件类型', 'format' => 'enum', 'extra' => array('options' => \Addons\IntegralShop\Repositor\IsSpreadsRecordRepositor::eventType())),
                array('name' => 'event_content', 'title' => '事件详情', 'format' => 'text'),
                array('name' => 'mark_op_type', 'title' => '积分操作', 'format' => 'enum', 'extra' => array('options' => \Addons\IntegralShop\Repositor\IsSpreadsRecordRepositor::opTypeHtml())),
                array('name' => 'mark', 'title' => '积分', 'format' => 'text'),
                array('name' => 'created_at', 'title' => '时间', 'format' => 'text'),
            ),
            'list_map' => array('mpid' => get_mpid()),
            'list_order' => array('id DESC'),
        ),
        'user_mark' => array(
            'name' => 'is_user',
            'meta_title' => '用户积分记录',
            'btn' => array(),
            'lists' => array(
                array('name' => 'id', 'title' => '主键', 'format' => 'hidden'),
                array('name' => 'openid', 'title' => '用户', 'format' => 'function', 'extra' => array(
                    'function_name' => 'get_fans_nickname',
                    'params' => '###'
                )),
                array('name' => 'mark', 'title' => '当前积分', 'format' => 'text'),
                array('name' => 'total_mark', 'title' => '历史积分', 'format' => 'text'),
            ),
            'list_map' => array('mpid' => get_mpid()),
            'list_order' => array('id DESC'),
        ),
    )
);
